home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 May / macformat-024.iso / Shareware City / Developers / TurboTCP 2.1 / TCL helper classes / CTCPApplication.cp next >
Encoding:
Text File  |  1995-01-18  |  2.8 KB  |  113 lines  |  [TEXT/MMCC]

  1. //
  2. // CTCPApplication.cp
  3. //
  4. //    TurboTCP library
  5. //    Application subclass
  6. //    TCL-specific class
  7. //
  8. //    Copyright © 1993-95, FrostByte Design / Eric Scouten
  9. //
  10.  
  11. #include "CTCPApplication.h"
  12.  
  13. #if !TurboTCP_TCL
  14.     #error: This file should be used with TCL projects only!
  15. #endif
  16.  
  17. #include "UTurboTCP.h"
  18.  
  19. extern Boolean gInBackground;
  20.  
  21. TCL_DEFINE_CLASS_M1(CTCPApplication, CApplication);
  22.  
  23. //***********************************************************
  24.  
  25. CTCPApplication::CTCPApplication()
  26. { }
  27.  
  28. CTCPApplication::CTCPApplication
  29.     (short    extraMasters,                // how many calls to MoreMasters
  30.                                     // I recommend a higher than usual value here…
  31.     Size        aRainyDayFund,                // size of TCL’s “rainy day” fund
  32.     Size        aCriticalBalance,            // same as for CApplication::IApplication
  33.     Size        aToolboxBalance)            // same as for CApplication::IApplication
  34.  
  35. : CApplication(extraMasters, aRainyDayFund, aCriticalBalance, aToolboxBalance)
  36. { }
  37.  
  38.  
  39. //***********************************************************
  40.  
  41. void CTCPApplication::ITCPApplication
  42.     (short    extraMasters,                // how many calls to MoreMasters
  43.                                     // I recommend a higher than usual value here…
  44.     Size        aRainyDayFund,                // size of TCL’s “rainy day” fund
  45.     Size        aCriticalBalance,            // same as for CApplication::IApplication
  46.     Size        aToolboxBalance)            // same as for CApplication::IApplication
  47.  
  48.     // old-style constructor retained for compatibility
  49.  
  50. {
  51.     CApplication::IApplication(extraMasters, aRainyDayFund, aCriticalBalance,
  52.                         aToolboxBalance);
  53. }
  54.  
  55.  
  56. //***********************************************************
  57.  
  58. void CTCPApplication::MakeHelpers()
  59.  
  60.     // Overriden to add the TCP driver to the list of "helpers."
  61.  
  62. {
  63.     // do standard TCL initialization
  64.  
  65.     CApplication::MakeHelpers();
  66.  
  67.     // set some default values
  68.     
  69.     cMaxSleepTime = 90;                    // don’t want to sleep for very long
  70.                                         // ALSO, must set the “Background Null Events”
  71.                                         //    checkbox under Set Project Type…
  72.                                         //    (SIZE flags)
  73.  
  74.     maxTCPEvents = 0;                        // use TurboTCP’s default event count/tick count
  75.     maxTCPTicks = 0;                        //    as defined in UTurboTCP::ProcessNetEvents()
  76.  
  77.     // initialize TCP driver
  78.  
  79.     UTurboTCP::InitTCP();
  80.  
  81. }
  82.  
  83.  
  84. // -- application shutdown --
  85.  
  86. //***********************************************************
  87.  
  88. Boolean CTCPApplication::Quit()
  89.  
  90.     // Dispose of the TCP driver object. Return true if quit was confirmed by each window.
  91.  
  92. {
  93.     Boolean reallyQuitting = CApplication::Quit();
  94.     if (reallyQuitting)
  95.         UTurboTCP::CloseTCP();
  96.     return reallyQuitting;
  97. }
  98.  
  99.  
  100. // -- foreground/background event trapping --
  101.  
  102. //***********************************************************
  103.  
  104. void CTCPApplication::Process1Event()
  105.  
  106.     // Here we tap into the event loop to process TCP completions and notifications, now freed
  107.     // from interrupt-level constraints on memory management.
  108.  
  109. {
  110.     UTurboTCP::ProcessNetEvents(maxTCPEvents, maxTCPTicks, gInBackground);
  111.     CApplication::Process1Event();
  112. }
  113.